﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DaInterFace;
using DaInterFace.PDA;
using DaInterFace.PDA.P02;

namespace P02
{
    /// <summary>
    /// A08 执行采样单结束操作
    /// </summary>
    public class A08 : IPDAChild
    {
        public void Code(IPDA handler, CodeResult CR, PDACodeUser user, String parameter)
        {
            P02A08P P = (P02A08P)handler.SerialApi.Deserialize(typeof(P02A08P), parameter, CR.SerialType);

            try
            {
                SqlParameter[] sps = new SqlParameter[1];
                sps[0] = new SqlParameter("@SampId", SqlDbType.NVarChar, 50);
                sps[0].Value = P.SampId;

                Recordset rs = handler.Data.ExeProcedure(P.BaseNo, "UPDATE KEW_PurchSampling SET FCheckBox=1 WHERE FID=@SampId", sps);

                if (rs.Enable)
                {
                    CR.Result = EnumResult.Normal;
                    CR.Message = String.Format("操作员{0}对账套{1}中的取样单进行了关闭操作{2}", user.UserName, P.BaseNo, P.SampId);
                }
                else
                {
                    CR.Result = EnumResult.Error;
                    CR.Message = "数据库错误";
                }
            }
            catch (Exception ex)
            {
                CR.Result = EnumResult.Error;
                CR.Message = String.Format("发生错误:{0}", ex.Message);
            }
        }
    }


}
